import sys
import settings

from django.conf.urls.defaults import patterns, include, url

from settings import PROJECT_ROOT

sys.path.append(PROJECT_ROOT)

# Uncomment the next two lines to enable the admin:
from django.contrib import admin

# Dajaxice
from dajaxice.core import dajaxice_autodiscover

from core import models

from core.views import test
from core.views import display
from core.views import filters
from core.views import view_scan
from core.views import view_item
from core.views import resources
from core.views import change_status

dajaxice_autodiscover()
admin.autodiscover()

urlpatterns = patterns('',
    url(r'^admin/', include(admin.site.urls)),
)

urlpatterns += patterns('',
    url(r'^$',        resources.dashboard),
    url(r'^up',       test.up),
    url(r'^filter/$', filters),
)

# Dajaxice
urlpatterns += patterns('',
    url(r'^%s/' % settings.DAJAXICE_MEDIA_PREFIX, include('dajaxice.urls')),
)

# List display Create Read
urlpatterns += patterns('',
    url(r'^scan$', display,    { 'model': models.Scan }),
    url(r'^link', display,     { 'model': models.Link }),
    url(r'^proxy', display,    { 'model': models.ProxyServer }),
    url(r'^provider', display, { 'model': models.Provider }),
    url(r'^schedule', display, { 'model': models.Schedule }),
    url(r'^variable', display, { 'model': models.Variable }),
)

# Item display View Update
urlpatterns += patterns('',
    url(r'^view/scan/(?P<id>\d{1,10})$',    view_scan),
    url(r'^view/link/(?P<id>\d{1,10})',     view_item, { 'model': models.Link }),
    url(r'^view/proxy/(?P<id>\d{1,10})',    view_item, { 'model': models.ProxyServer }),
    url(r'^view/provider/(?P<id>\d{1,10})', view_item, { 'model': models.Provider }),
    url(r'^view/schedule/(?P<id>\d{1,10})', view_item, { 'model': models.Schedule }),
    url(r'^view/variable/(?P<id>\d{1,10})', view_item, { 'model': models.Variable }),
)

# Item display Enable Disable (Possibly will be implemented for Schedules)
urlpatterns += patterns('core.views',
    url(r'^enable/proxy/(?P<id>\d{1,10})',  change_status, { 'model': models.ProxyServer }),
    url(r'^disable/proxy/(?P<id>\d{1,10})', change_status, { 'model': models.ProxyServer }),
)

